import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import SelectUtil from '@/SelectUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 金钟罩
 **/
export default class WS_ArmorLock extends AbilityBase {
    static instance: WS_ArmorLock;
    buffType: AppBuffType = {
        id: 'buff_WS_ArmorLock',
        art: this.art,
        name: this.abilityName,
        ubertip: '增加大量护甲，并且持续对周围的敌人造成火焰伤害',
        targetAttach: 'origin',
        targetArt: 't_divineshieldtarget.mdx',
        attribute: {},
        dur: 5,
        interval: 1,
        onInterval: this.buffInterval.bind(this),
    };
    constructor(id: string = 'Ajzz') {
        super(id);
        WS_ArmorLock.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        // let buff = BuffUtil.addBuff(source, this.buffType.id, source);
        let lv = this.getAbilityLevel(source);
        let fp = UnitCommon.getFullProperty(source);
        let armor = (fp / 5) * lv;
        // buff.attribute.附加护甲 = armor;
        BuffCommon.addBuff({
            target: source,
            caster: source,
            buffTypeId: this.buffType.id,
            ablityId: this.id,
            attribute: {
                附加护甲: armor,
            },
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
    buffInterval(buff: Buff) {
        let es = SelectUtil.getEnemyUnitsInRange(buff.getCaster(), 175);
        let lv = this.getAbilityLevel(buff.getCaster());
        let dmg = 18 * lv + UnitCommon.取法强(buff.getCaster()) * (0.6 + 0.36 * lv);
        DamageSystemInstance.applyAoeMagicDamage(es, buff.getCaster(), dmg, 'fire', this.id);
    }
}
